import Vue from 'vue';
import Router from 'vue-router';
import Dashboard from '../views/Dashboard';

import UserList from '../views/user/UserList';
import AddUser from '../views/user/AddUser';

import MysqlList from '../views/database/MysqlList';
import AddMysql from '../views/database/AddMysql';
import RedisList from '../views/database/RedisList';
import AddRedis from '../views/database/AddRedis';

import LanguageHome from '../views/language/LanguageHome';
import JavaInfo from '../views/language/JavaInfo';
import NodeInfo from '../views/language/NodeInfo';
import PythonInfo from '../views/language/PythonInfo';

Vue.use(Router);

// 用户路由数组
let userRouterArr = [
  {
    path: 'user/userList',
    name: 'UserList',
    component: UserList
  },
  {
    path: 'user/addUser',
    name: 'AddUser',
    component: AddUser
  }
];

// 数据库路由数组
let databaseRouterArr = [
  {
    path: 'database/mysqlList',
    name: 'MysqlList',
    component: MysqlList
  },
  {
    path: 'database/addMysql',
    name: 'AddMysql',
    component: AddMysql
  },
  {
    path: 'database/RedisList',
    name: 'RedisList',
    component: RedisList
  },
  {
    path: 'database/addRedis',
    name: 'AddRedis',
    component: AddRedis
  }
];

// 语言路由数组
let languageRouterArr = [
  {
    path: 'language/languageHome',
    name: 'LanguageHome',
    component: LanguageHome
  },
  {
    path: 'language/javaInfo',
    name: 'JavaInfo',
    component: JavaInfo
  },
  {
    path: 'language/nodeInfo',
    name: 'NodeInfo',
    component: NodeInfo
  },
  {
    path: 'language/pythonInfo',
    name: 'PythonInfo',
    component: PythonInfo
  }
];

const router = new Router({
  routes: [
    {
      path: '/',
      redirect: '/dashboard'
    },
    {
      path: '/dashboard',
      name: 'Dashboard',
      component: Dashboard,
      children: [...userRouterArr, ...languageRouterArr, ...databaseRouterArr]
    }
  ]
});
export default router;
